import {
    friend,
    move,
    user
} from "./msg"

export default class MsgManager{
    private id2Msg:Map<number,any> = new Map();
    private msg2Id:Map<any,number> = new Map();



    private static  _instance = new MsgManager()
    private constructor(){
        this.registerMsg()
    }

    public static get instance(){
        return MsgManager._instance
    }
    registerMsg() {
        this.id2Msg.set(-202159303,friend.UserInfo)
        this.msg2Id.set(friend.UserInfo,-202159303)
        this.id2Msg.set(-309835929,friend.C2S_FriendListReq)
        this.msg2Id.set(friend.C2S_FriendListReq,-309835929)
        this.id2Msg.set(-209655257,friend.S2C_FriendListResp)
        this.msg2Id.set(friend.S2C_FriendListResp,-209655257)
        this.id2Msg.set(-1330431105,move.C2S_SyncPosition)
        this.msg2Id.set(move.C2S_SyncPosition,-1330431105)
        this.id2Msg.set(-1410039937,move.S2C_SyncPosition)
        this.msg2Id.set(move.S2C_SyncPosition,-1410039937)
        this.id2Msg.set(-452433618,user.C2S_Login)
        this.msg2Id.set(user.C2S_Login,-452433618)
        this.id2Msg.set(-1901885695,user.Player)
        this.msg2Id.set(user.Player,-1901885695)
        this.id2Msg.set(-2059391458,user.S2C_LoginResp)
        this.msg2Id.set(user.S2C_LoginResp,-2059391458)
        this.id2Msg.set(-432959961,user.S2C_AddPlayer)
        this.msg2Id.set(user.S2C_AddPlayer,-432959961)

    }

    getMsg(msgId:number){
        return this.id2Msg.get(msgId)
    }
    getMsgId(msgType:any){
        return this.msg2Id.get(msgType)
    }
}
